// @ts-nocheck

module.exports = (api) => {
  const { dependencies = {} } = api.service.pkg;

  // 应用 webpack配置
  const chainWebpack = (callback) => {
    api.chainWebpack((config) => {
      config.devServer.headers({
        "Access-Control-Allow-Origin": "*",
      });
      callback(config);
    });
  };
  if (!dependencies.qiankun) {
    const name = process.env.VUE_APP_SUBAPPNAME;
    chainWebpack((config) => {
      config.output
        .library(`${name}-[name]`)
        .libraryTarget("umd")
        .jsonpFunction(`webpackJsonp_${name}`);
    });
  } else {
    chainWebpack((config) => {
      config.devServer.historyApiFallback = true;
    });
  }
};
